package com.chixing.service.impl;

import com.chixing.mapper.CarMapper;
import com.chixing.mapper.StoreMapper;
import com.chixing.pojo.*;
import com.chixing.service.BrandStepService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BrandStepServiceImpl implements BrandStepService {
    @Autowired
    private CarMapper carMapper;
    @Autowired
    private StoreMapper storeMapper;

//    @Override
//    public ServerResponse getByCarId(Integer carId) {
//        CarExample carExample = new CarExample();
//        carExample.createCriteria().andCarIdEqualTo(carId);
//
//        StoreExample storeExample = new StoreExample();
//        List<Store> storeList = storeMapper.selectByExample(storeExample);
//        List<StoreCarVO> storeCarVOList = new ArrayList<>();
//        for (Store store:storeList){
//            Car car1 = carMapper.selectByPrimaryKey(store.getCarId());
//            StoreCarVO storeCarVO = new StoreCarVO(store,car1);
//            storeCarVOList.add(storeCarVO);
//        }
//        return ServerResponse.getSucccess(storeCarVOList);
//    }

    @Override
    public ServerResponse getByStoreId(Integer storeId) {
        Store store ;
        if(storeId != null ) {
            store = storeMapper.selectByPrimaryKey(storeId);
            if (store != null) {
                return ServerResponse.getSucccess(store);
            }
        }
      return ServerResponse.deleteFail(null);
    }
}
